using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration.Provider;
using AAM.BIZ;

namespace AAM.DAL
{
    public class BizProviderManager : Dictionary<string,ProviderBase>
    {

        public static BizProviderManager Instance = new BizProviderManager();

        private BizProviderManager()
        {
        }

        public ProviderBase GetProvider(IBizObject obj) { return GetProvider(obj.ID); }
        public ProviderBase GetProvider(ObjectID oid) { return GetProvider(oid.Type); }
        public ProviderBase GetProvider(ObjectType type) { return GetProvider(type.Name); }
        public ProviderBase GetProvider(string name)
        {
            try
            {
                return this[name];
            }
            catch (KeyNotFoundException)
            {
                ProviderBase provider = this[name] = BizProviderConfiguration.GetProvider(name);
                return provider;
            }
        }

    }
}
